<%@ page import="cn.educate.service.AICommandTaskManager" %>
<%@ page import="java.util.List" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>AI任务管理工具</title>
    <!-- 引入Bootstrap CSS -->
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #f8f9fa;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        .container {
            max-width: 1200px;
            background-color: white;
            border-radius: 10px;
            box-shadow: 0 0 20px rgba(0,0,0,0.1);
            padding: 30px;
            margin-top: 30px;
            margin-bottom: 30px;
        }
        h1 {
            color: #343a40;
            margin-bottom: 30px;
            font-weight: 600;
            padding-bottom: 15px;
            border-bottom: 1px solid #eee;
        }
        h2 {
            color: #495057;
            font-size: 1.5rem;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 1px solid #eee;
        }
        .form-group label {
            font-weight: 500;
            color: #495057;
        }
        .btn-primary {
            background-color: #4e73df;
            border-color: #4e73df;
            padding: 8px 20px;
            font-weight: 500;
            transition: all 0.3s;
        }
        .btn-primary:hover {
            background-color: #3a5ec0;
            border-color: #3a5ec0;
            transform: translateY(-1px);
        }
        .table {
            margin-top: 20px;
            border-collapse: separate;
            border-spacing: 0;
            border-radius: 8px;
            overflow: hidden;
        }
        .table thead th {
            background-color: #4e73df;
            color: white;
            font-weight: 500;
            border: none;
            padding: 12px 15px;
        }
        .table tbody tr {
            transition: all 0.2s;
        }
        .table tbody tr:hover {
            background-color: #f8f9fa;
            transform: translateX(5px);
        }
        .table tbody td {
            padding: 12px 15px;
            vertical-align: middle;
            border-top: 1px solid #eee;
        }
        .alert {
            border-radius: 8px;
            padding: 12px 20px;
        }
        #taskDesc {
            border-radius: 5px;
            padding: 10px 15px;
            border: 1px solid #ced4da;
            transition: all 0.3s;
        }
        #taskDesc:focus {
            border-color: #4e73df;
            box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25);
        }
    </style>
</head>
<body>
<div class="container mt-5">
    <h1 class="text-center">AI任务管理工具 v1.0</h1>
    <!-- 显示错误信息 -->
    <% if (request.getAttribute("error") != null) { %>
    <div class="alert alert-danger" role="alert">
        <%= request.getAttribute("error") %>
    </div>
    <% } %>
    <form action="task" method="post" class="mt-5">
        <div class="form-group">
            <label for="taskDesc">任务描述:</label>
            <input type="text" class="form-control" id="taskDesc" name="taskDesc" placeholder="请输入任务描述">
        </div>
        <button type="submit" class="btn btn-primary">添加任务</button>
    </form>
    <div class="mt-5" id="tasks">
        <h2>任务列表:</h2>
        <table class="table">
            <thead>
            <tr>
                <th>创建时间</th>
                <th>类别</th>
                <th>描述</th>
            </tr>
            </thead>
            <tbody>
            <%
                AICommandTaskManager manager = AICommandTaskManager.getInstance();
                List<AICommandTaskManager.Task> tasks = manager.listTasks();
                for (AICommandTaskManager.Task task : tasks) {
            %>
            <tr>
                <td><%= task.createdTime %></td>
                <td><%= task.category %></td>
                <td><%= task.description %></td>
            </tr>
            <% } %>
            </tbody>
        </table>
    </div>
</div>
<!-- 引入Bootstrap JS和依赖 -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.3/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>